<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Help Request Page</title>
<link rel="stylesheet" type="text/css" href="PersonalPage.css" />
</head>
<%@page import="entities.*"%>
<%@page import="java.util.*"%>
<%@page import="sessionbeans.FriendshipBean" %>
<%
	RegisteredUser user = (RegisteredUser) request.getSession()
			.getAttribute("visitinguser");
	List<Declares> abilities = (List<Declares>) request.getSession().getAttribute("visitinguserabilities");
	String friendshipState = (String)request.getSession().getAttribute("friendshipstate");
	String helpRequestOutcome = (String) request.getSession().getAttribute("helprequestoutcome");
%>
<body style="background-color: #94C0D6">
	<img alt="" src="Swim.jpg" style="height: 64px; width: 200px;">
	<form
		style="background-color: #A6B0DB; border-bottom-width: thin; border-right-width: thin; border-left-width: thin; border-top-width: thin; border-top-color: #8080FF; border-right-color: #8080FF; border-top-style: solid; border-right-style: solid; height: 24px;">
		<a href="SearchServlet">Back.</a> <a href="LogOutServlet">Logout.</a>
	</form>
<form style="width: 453px; background-color: #8080FF; height: 22px; vertical-align: middle; border-top-style: solid; border-top-color: #8080C0; border-right-color: #8080C0; border-right-width: thin; border-right-style: solid; border-top-width: thin">
			<center><b><%
				out.print(user.getSurname() + " " + user.getName() + " (alias "
						+ user.getUserId() + ")");
			%></b></center>
</form>
	<fieldset style="width: 995px;">
		<div class=field style="width: 276px;">
			<form style="height: 164px; width: 172px">

				<a href="SendHelpRequestPage.jsp"><br> Send Help Request <br></a>
				<%
				if  (friendshipState.equals(FriendshipBean.CAN_SEND_REQUEST)) {
					out.print("<a href=\"SendFriendshipServlet?receiver=" + user.getUserId() + "&&sender=" + request.getSession().getAttribute("userId") + "\">" + friendshipState + "<br></a>");
					} else if(friendshipState.equals(FriendshipBean.PENDING_REQUEST)){
						out.println("<a href=\"PendingFriendshipServlet" + "\">" + friendshipState + "<br></a>");
						} else if(friendshipState.equals(FriendshipBean.REQUEST_SENT)){
							out.println(friendshipState);
						}%>		
				<a href="SendFeedbackPage.jsp">Send Feedback <br></a>
				
			</form>
		</div>
		<div class=field style="width: 276px; height: 839px">
		<% if(helpRequestOutcome != null){
			out.println(helpRequestOutcome);
			request.getSession().removeAttribute("helprequestoutcome");
		}
			%>
				<form  action = "SendHelpRequestServlet" class=form-inside
				style="width: 933px; height: 696px; list-style-type: disc">
				<fieldset style="width: 882px; background-color: #A6B0DB; border-bottom-style: none; border-top-style: none; border-left-style: none; border-right-style: none; height: 691px">
					<div class=field style="width: 276px; border-top-style: none; border-right-width: thin; border-right-style: none; border-top-width: thin">
						<table style="height: 83px; width: 256px; background-color: #8080C0">
							<tr>
								<td style="background-color: #8080FF;">Help Request</td>
								<td>(*) all fields are mandatory</td>
							</tr>
							<tr>
								<td><b> Receiver:</b></td>
								<td style="width: 245px;"><input type="text"
									name="receiver" readonly
									<%out.println("value=" + user.getUserId());%>
									style="width: 390px;"></td>
							</tr>
							<tr>
								<td><b> Place:</b></td>
								<td><input type="text" name="place"
									style="width: 388px;"></td>
							</tr>
							<tr>
								<td style="width: 91px; "><b> Description:</b>
								<br/>(max 255 chars)</td>
								<td><textarea  name="description" style="height: 126px; width: 386px; "></textarea></td>
							</tr>
							<tr>
								<td><b> Retribution (in EUR):</b></td>
								<td><input type="text" name="retribution"
									style="width: 388px;"></td>
							</tr>
	<tr>
								<td style="height: 85px;"><b> Ability Requested:</b></td>
								<td><b>Select one ability</b><br> <br>
								</B><select name="ability" id="Select1"
									size="
    								<%if (abilities != null) {
											int length = abilities.size();
											out.print(length);
											} else {
									out.print(0);
									}%>"
									multiple="multiple" style="height: 93px; width: 386px">
										<%
											if (abilities != null){
													for (Declares d : abilities)
														out.println("<option name = \"ability\" value=\""
																+ d.getKey().getAbility().getName() + "\">" + d.getKey().getAbility().getName() + "</option>");
											}
										%>
								</select></td>
							</tr>
							<tr><td></td>
								<td><input type="submit" value="Send Help Request" style="background-color: #8080FF"></td>
							</tr>
						</table>
					</div>
				</fieldset>
			</form>
		</div>
	</fieldset>



</body>

</html>